package com.gsn.poker.asset;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.GsnImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.gsn.engine.gdx.GsnParticleActor;
import com.gsn.engine.gdx.assets.GsnManagerTexture;
import com.gsn.poker.game.MyPoker;

public class ChatTexture extends GsnManagerTexture {
	public static ChatTexture _instance;

	protected ChatTexture() {
		super();
	}

	public static ChatTexture inst() {
		if (_instance == null)
			_instance = new ChatTexture();
		return _instance;
	}

	static public final String tag = "Chat Texture";

	// static public List<AtlasRegion> timeCho;

	public AtlasRegion emo1;
	public AtlasRegion emo2;
	public AtlasRegion emo3;
	public AtlasRegion emo4;
	public AtlasRegion emo5;
	public AtlasRegion emo6;
	public AtlasRegion emo7;
	public AtlasRegion emo8;
	public AtlasRegion emo9;
	public AtlasRegion emo10;
	public AtlasRegion emo11;
	public AtlasRegion emo12;
	public AtlasRegion emo13;
	public AtlasRegion emo14;
	public AtlasRegion emo15;
	public AtlasRegion emo16;
	public AtlasRegion emo17;
	public AtlasRegion emo18;
	public AtlasRegion emo19;
	public AtlasRegion emo20;
	public AtlasRegion iconMaskEmotion;
	public AtlasRegion iconMaskEmotionPress;
	public AtlasRegion bgEmotion;

	public AtlasRegion closeBtn;
	public AtlasRegion closeBtnDown;
	public AtlasRegion sendBtn;
	public AtlasRegion sendBtnDown;
	public ParticleEffect clickEff;
	public ParticleEffect jackpotEff;

	public boolean assigned = false;

	/*
	 * public void assignContent(PokerTexture obj) { if (!onceAssign) return;
	 * 
	 * clickEff = GsnParticleActor.loadParticleEffect(resolver,
	 * "poker/particle/click.p");
	 * 
	 * TextureAtlas atlas = manager.get("poker/content/pack",
	 * TextureAtlas.class); fontMedium = manager.get("poker/font/medium.fnt",
	 * BitmapFont.class); fontLarge = manager.get("poker/font/large.fnt",
	 * BitmapFont.class); // board = atlas.findRegion("BG1");
	 * 
	 * Field[] fields = PokerTexture.class.getFields(); for (int i = 0; i <
	 * fields.length; i++) { Field f = fields[i]; if
	 * (Modifier.isPublic(f.getModifiers()) &&
	 * Modifier.isStatic(f.getModifiers())) { try { if (f.get(obj) != null)
	 * continue; if (f.getType() == AtlasRegion.class) { AtlasRegion region =
	 * atlas.findRegion(f.getName()); f.set(obj, region); if (region == null) {
	 * Gdx.app.log(tag, "region = null voi : " + f.getName()); } }
	 * 
	 * if (f.getType() == List.class) { List<AtlasRegion> region =
	 * atlas.findRegions(f.getName()); f.set(obj, region); if (region == null) {
	 * Gdx.app.log(tag, "List<region> = null voi : " + f.getName()); } } } catch
	 * (Exception e) { e.printStackTrace(); } } } onceAssign = false; }
	 */
	@Override
	public void assignTask() {

		clickEff = GsnParticleActor.loadParticleEffect(resolver, "poker/particle/click.p");
		jackpotEff = GsnParticleActor.loadParticleEffect(resolver, "poker/particle/jackpot.p");
		TextureAtlas atlas = manager.get("chat/pack", TextureAtlas.class);

		autoAssignAtlas(atlas);

		// emo1 = atlas.findRegion("Emo1");
		// emo2 = atlas.findRegion("Emo2");
		// emo3 = atlas.findRegion("Emo3");
		// emo4 = atlas.findRegion("Emo4");
		// emo5 = atlas.findRegion("Emo5");
		// emo6 = atlas.findRegion("Emo6");
		// emo7 = atlas.findRegion("Emo7");
		// emo8 = atlas.findRegion("Emo8");
		// emo9 = atlas.findRegion("Emo9");
		// emo10 = atlas.findRegion("Emo10");
		// emo11 = atlas.findRegion("Emo11");
		// emo12 = atlas.findRegion("Emo12");
		// emo13 = atlas.findRegion("Emo13");
		// emo14 = atlas.findRegion("Emo14");
		// emo15 = atlas.findRegion("Emo15");
		// emo16 = atlas.findRegion("Emo16");
		// emo17 = atlas.findRegion("Emo17");
		// emo18 = atlas.findRegion("Emo18");
		// emo19 = atlas.findRegion("Emo19");
		// emo20 = atlas.findRegion("Emo20");
		// closeBtn = atlas.findRegion("closeBtn");
		// closeBtnDown = atlas.findRegion("closeBtnDown");
		// sendBtn = atlas.findRegion("sendBtn");
		// sendBtnDown = atlas.findRegion("sendBtnDown");
		//
		assigned = true;

		Gdx.app.log(tag, "DA FINISH ");
	}

	// board = atlas.findRegion("BG1")
	public void loadTexture() {
		manager.load("chat/pack", TextureAtlas.class);

	}

	public void scaleActor(Actor actor) {
		// actor.scaleX = actor.scaleY = MyPoker.game.scale;
		if (actor instanceof GsnImageButton)
			((GsnImageButton) actor).setScale(MyPoker.game.scale);
		else {
			actor.width = actor.width * MyPoker.game.scale;
			actor.height = actor.height * MyPoker.game.scale;
		}
	}
}
